Skip to content

fix: LB Creation avoid 404 API errors due to non-needed patches#12835

Open
ZhyliaievD wants to merge 1 commit intoapache:mainfrom
PlaytikaOSS:fix/nsx-lb-404-api-errors
Open

fix: LB Creation avoid 404 API errors due to non-needed patches#12835
ZhyliaievD wants to merge 1 commit intoapache:mainfrom
PlaytikaOSS:fix/nsx-lb-404-api-errors

Conversation

@ZhyliaievD
Copy link
Copy Markdown

Description

  • Avoid unnecessary NSX load balancer patch calls when the target resource already exists and does not need updating.
  • Reuse existing LB active monitor profiles instead of patching them again, which prevents avoidable 404 API errors during LB creation.
  • Skip server pool patching when the current NSX pool already has the same members, and skip virtual server patching when the virtual server already exists.
  • Fix createAndAddNsxLbVirtualServer() to check for an existing virtual server using the virtual server name, so existing virtual servers are detected correctly and not patched again

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR optimizes NSX load balancer creation by avoiding unnecessary API PATCH calls when resources already exist and don't need updating. It fixes a bug where createAndAddNsxLbVirtualServer() was checking for an existing virtual server using the wrong name (the LB service name instead of the virtual server name), causing it to never detect existing virtual servers.

Changes:

  • Skip monitor profile patching when the profile already exists in NSX, and skip server pool patching when the pool already has the same members
  • Fix the virtual server existence check to use the correct virtual server name instead of the LB service name, so existing virtual servers are detected and not re-patched
  • Add comprehensive unit tests covering all the new skip/patch scenarios

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
plugins/network-elements/nsx/src/main/java/org/apache/cloudstack/service/NsxApiClient.java Add existence checks for monitor profiles, server pools, and virtual servers to avoid unnecessary NSX API patch calls; fix virtual server lookup to use correct name
plugins/network-elements/nsx/src/test/java/org/apache/cloudstack/service/NsxApiClientTest.java Add tests for monitor profile reuse, pool member comparison skip/patch logic, and virtual server existence detection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 96.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 18.06%. Comparing base (b744824) to head (94cabcd).

Files with missing lines Patch % Lines
...va/org/apache/cloudstack/service/NsxApiClient.java 96.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main   #12835      +/-   ##
============================================
+ Coverage     18.02%   18.06%   +0.03%     
- Complexity    16450    16482      +32     
============================================
  Files          5968     5968              
  Lines        537086   537121      +35     
  Branches      65961    65966       +5     
============================================
+ Hits          96819    97012     +193     
+ Misses       429347   429181     -166     
- Partials      10920    10928       +8     
Flag Coverage Δ
uitests 3.53% <ø> (ø)
unittests 19.23% <96.00%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ZhyliaievD ZhyliaievD force-pushed the fix/nsx-lb-404-api-errors branch from 9f079d8 to 4ea0f3d Compare March 17, 2026 13:04
@DaanHoogland DaanHoogland requested a review from Copilot March 17, 2026 13:57
@DaanHoogland
Copy link
Copy Markdown
Contributor

@blueorangutan package

@blueorangutan
Copy link
Copy Markdown

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with no SystemVM templates. I'll keep you posted as I make progress.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR avoids unnecessary NSX API patch calls during load balancer creation by checking if resources already exist before patching, preventing 404 errors.

Changes:

  • Skip server pool patching when existing pool has identical members; skip virtual server patching when it already exists.
  • Reuse existing LB active monitor profiles instead of re-patching them, fetching by ID directly rather than listing all profiles.
  • Fix createAndAddNsxLbVirtualServer() to look up the virtual server by its own name instead of the LB service name.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
NsxApiClient.java Added existence checks for pools, monitor profiles, and virtual servers before issuing patch calls; fixed virtual server lookup key.
NsxApiClientTest.java Added tests covering skip/patch scenarios for server pools, monitor profiles, virtual servers, and error handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@blueorangutan
Copy link
Copy Markdown

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17174

Fix existing lbVirtualServer search by lbVirtualServerName
@ZhyliaievD
Copy link
Copy Markdown
Author

@blueorangutan test

1 similar comment
@sureshanaparti
Copy link
Copy Markdown
Contributor

@blueorangutan test

@blueorangutan
Copy link
Copy Markdown

@sureshanaparti a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link
Copy Markdown

[SF] Trillian test result (tid-15714)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 59477 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12835-t15714-kvm-ol8.zip
Smoke tests completed. 145 look OK, 6 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
test_attach_and_distribute_multiple_volumes Failure 88.65 test_attach_multiple_volumes.py
test_10_vpc_tier_kubernetes_cluster Failure 3752.85 test_kubernetes_clusters.py
ContextSuite context=TestListIdsParams>:teardown Error 1.14 test_list_ids_parameter.py
test_01_snapshot_root_disk Error 4.03 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 47.07 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 47.07 test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:teardown Error 29.85 test_snapshots.py
test_01_snapshot_usage Error 20.89 test_usage.py
test_01_vpn_usage Error 1.11 test_usage.py
test_01_redundant_vpc_site2site_vpn Failure 367.37 test_vpc_vpn.py
test_01_vpc_site2site_vpn_multiple_options Failure 416.16 test_vpc_vpn.py
test_01_vpc_site2site_vpn Failure 248.58 test_vpc_vpn.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants